#ifndef __HEAPSORT__
#define __HEAPSORT__
#include "priorityqueue.h"

template <class item>
void heapsort(item arr[], int left, int right){
	int len = right - left + 1;
	for(int i = len/2; i >=0; --i){
		fixdown(arr, i, right);
	}
	for(int i = right; i >= left; --i){
		exchange(arr[i], arr[0]);
		fixdown(arr, 0, i-1);
	}
}
#endif